﻿using System;
using System.Linq;

namespace Microsoft.Office.OneNote
{
    internal abstract class DefaultValueProvider
    {
        public abstract object GetValue();

        public static DefaultValueProvider NewInstance<T>()
            where T : class, new()
        {
            return NewInstanceProvider<T>.Value;
        }

        private sealed class NewInstanceProvider<T> : DefaultValueProvider
            where T : class, new()
        {
            public override object GetValue()
            {
                return new T();
            }

            public static readonly NewInstanceProvider<T> Value = new NewInstanceProvider<T>();
        }
    }
}
